
import { v4 as uuidv4 } from 'uuid'

import KaseoRuntime from "./kaseo/runtime/KaseoRuntime";
import KaseoDeviceInterface from './kaseo/runtime/KaseoDeviceInterface';

export var appEnv = { inited: false }  /* for HMR */

export const KASEO_MAIN = new KaseoRuntime()
export const SESSION_ID = uuidv4()


export function gRegisterDevice(devInterface: KaseoDeviceInterface) {
    if (appEnv.inited) {
        console.warn('Kaseo: duplicated device registration')
    }

    KASEO_MAIN.registerDevice(devInterface)
}


export function gKaseoBoot() {
    if (!appEnv.inited)
        KASEO_MAIN.$$boot()
}


export function appInitFinished() {
    appEnv.inited = true
}


console.log('Kaseo: app inited with session id: ' + SESSION_ID)
